{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "332126f9-3524-4223-bcc6-24b9818b77b5",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from mythic import mythic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "abfa531f-5e7a-400b-910c-92a62106ccbe",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "mythic_instance = await mythic.login(\n",
    "        username=\"mythic_admin\",\n",
    "        password=\"mythic_password\",\n",
    "        server_ip=\"mythic_nginx\",\n",
    "        server_port=7443,\n",
    "        timeout=-1\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c8079b72-60f8-426c-9562-3a2a0cef035a",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Register a new file with Mythic ################\n",
    "resp = await mythic.register_file(\n",
    "   mythic=mythic_instance, filename=\"test.txt\", contents=b\"this is a test\"\n",
    ")\n",
    "print(f\"registered file UUID: {resp}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d84a9fe1-589e-49ec-a843-4c89a877e684",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Update a file's comment ################\n",
    "response = await mythic.update_file_comment(mythic=mythic_instance, file_uuid=resp, comment=\"i was auto updated\")\n",
    "print(response)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "af853176-1f90-4731-afad-b95f70e9748f",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Downloading a file with chunking ################\n",
    "async for t in mythic.download_file_chunked(\n",
    "    mythic=mythic_instance, file_uuid=resp\n",
    "):\n",
    "    print(f\"[+] got chunk \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "94185a9b-d5b3-4f41-80b0-512982b98a6e",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Downloading a file without chunking ################\n",
    "file_bytes = await mythic.download_file( mythic=mythic_instance, file_uuid=resp )\n",
    "print(file_bytes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "92e53c81-4fb5-479b-9869-adedb627821a",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Get metadata about all downloaded files ################\n",
    "async for downloaded_file in mythic.get_all_downloaded_files(mythic=mythic_instance):\n",
    "    print(downloaded_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a61eb2d3-ed3d-48ff-98bc-fe1418a576a1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Get metadata about all downloaded screenshots ################\n",
    "async for screenshot in mythic.get_all_screenshots(mythic=mythic_instance):\n",
    "    print(screenshot)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a4397b53-56d1-4de6-99d8-8389b4de9759",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# ################ Get metadata about all uploaded files ################\n",
    "async for upload in mythic.get_all_uploaded_files(mythic=mythic_instance):\n",
    "    print(upload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6bd528d7-eb69-4f5c-a6f5-6543ca285c68",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
